using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using llano.util;
using llano.data;
using llano.service;
using CF.Data;
using System.Text.RegularExpressions;
namespace CF.Service
{
	public class TableQuery : IQueryBuilder
	{
        public string searchValue = string.Empty;
		public Dictionary<string, object> MakeSearchWhere(NameValueCollection ps)
		{
			Dictionary<string, object> args = new Dictionary<string, object>();
			List<string> parts = new List<string>();
			Dictionary<string, object> parameters = new Dictionary<string, object>();
			String propName="id";
			if (ps[propName] != null && ps[propName].Length > 0)
			{
				parts.Add(BaseHelper.MakeCriteria(propName, "="));
				parameters.Add(propName, ps[propName]);
			}

            propName = "Name";
            if (ps[propName] != null && ps[propName].Length > 0)
            {
                parts.Add(BaseHelper.MakeCriteria(propName, " like "));
                parameters.Add(propName, "%" + ps[propName] + "%");
            }
            propName = "ProjectID";
			if (ps[propName] != null && ps[propName].Length > 0)
			{
				parts.Add(BaseHelper.MakeCriteria(propName, " = "));
				parameters.Add(propName, ps[propName]);
			}
			

			string hql = parts.Count > 0 ? BaseHelper.SqlWhereJoin(parts) : "1=1";
			//hql = hql + " order by s.Hot desc";
			args.Add("hql", hql);
			args.Add("parameters", parameters);
			return args;
		}
	}
}